package com.px.task.controller;

import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.core.page.TableDataInfo;
import com.px.common.enums.BusinessType;
import com.px.common.utils.poi.ExcelUtil;
import com.px.framework.aes.AesSecurityParameter;
import com.px.task.domain.TaskCalendarBlacklist;
import com.px.task.service.ITaskCalendarBlacklistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 任务黑名单,记录循环任务中被删除的单次任务Controller
 * 
 * @author WRJ
 * @date 2024-08
 */
@Api("任务黑名单,记录循环任务中被删除的单次任务")
@RestController
@RequestMapping("/task/blacklist")
public class TaskCalendarBlacklistController extends BaseController
{
    @Autowired
    private ITaskCalendarBlacklistService taskCalendarBlacklistService;

    /**
     * 查询任务黑名单,记录循环任务中被删除的单次任务列表
     */
    @ApiOperation("查询任务黑名单,记录循环任务中被删除的单次任务列表")
    @PreAuthorize("@ss.hasPermi('task:blacklist:query')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(TaskCalendarBlacklist taskCalendarBlacklist)
    {
        startPage();
        List<TaskCalendarBlacklist> list = taskCalendarBlacklistService.selectTaskCalendarBlacklistList(taskCalendarBlacklist);
        return getDataTable(list);
    }

    /**
     * 导出任务黑名单,记录循环任务中被删除的单次任务列表
     */
    @ApiOperation("导出任务黑名单,记录循环任务中被删除的单次任务列表")
    @PreAuthorize("@ss.hasPermi('task:blacklist:query')")
    @Log(title = "任务黑名单,记录循环任务中被删除的单次任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter
    public void export(HttpServletResponse response, TaskCalendarBlacklist taskCalendarBlacklist)
    {
        List<TaskCalendarBlacklist> list = taskCalendarBlacklistService.selectTaskCalendarBlacklistList(taskCalendarBlacklist);
        ExcelUtil<TaskCalendarBlacklist> util = new ExcelUtil<TaskCalendarBlacklist>(TaskCalendarBlacklist.class);
        util.exportExcel(response, list, "任务黑名单,记录循环任务中被删除的单次任务数据");
    }

    /**
     * 获取任务黑名单,记录循环任务中被删除的单次任务详细信息
     */
    @ApiOperation("获取任务黑名单,记录循环任务中被删除的单次任务详细信息")
    @PreAuthorize("@ss.hasPermi('task:blacklist:query')")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(taskCalendarBlacklistService.selectTaskCalendarBlacklistById(id));
    }

    /**
     * 新增任务黑名单,记录循环任务中被删除的单次任务
     */
    @ApiOperation("新增任务黑名单,记录循环任务中被删除的单次任务")
    @PreAuthorize("@ss.hasPermi('task:blacklist:edit')")
    @Log(title = "任务黑名单,记录循环任务中被删除的单次任务", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody TaskCalendarBlacklist taskCalendarBlacklist)
    {
        return toAjax(taskCalendarBlacklistService.insertTaskCalendarBlacklist(taskCalendarBlacklist));
    }

    /**
     * 修改任务黑名单,记录循环任务中被删除的单次任务
     */
    @ApiOperation("修改任务黑名单,记录循环任务中被删除的单次任务")
    @PreAuthorize("@ss.hasPermi('task:blacklist:edit')")
    @Log(title = "任务黑名单,记录循环任务中被删除的单次任务", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody TaskCalendarBlacklist taskCalendarBlacklist)
    {
        return toAjax(taskCalendarBlacklistService.updateTaskCalendarBlacklist(taskCalendarBlacklist));
    }

    /**
     * 删除任务黑名单,记录循环任务中被删除的单次任务
     */
    @ApiOperation("删除任务黑名单,记录循环任务中被删除的单次任务")
    @PreAuthorize("@ss.hasPermi('task:blacklist:remove')")
    @Log(title = "任务黑名单,记录循环任务中被删除的单次任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(taskCalendarBlacklistService.deleteTaskCalendarBlacklistByIds(ids));
    }
}
